import dayjs from "dayjs";
import { ValueTransformer } from "typeorm";

export class DateTimeTransformer implements ValueTransformer {
  to(): Date {
    return dayjs().toDate();
  }

  from(value: string): string {
    if (!value) return "";
    return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
  }
}
